package org.example.java8.date;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class DateFormatTest {
    public static void main(String[] args) {
        LocalDate localDate = LocalDate.now();
        String format = localDate.format(DateTimeFormatter.BASIC_ISO_DATE);
        String format2 = localDate.format(DateTimeFormatter.ISO_LOCAL_DATE);
        System.out.println(format);
        System.out.println(format2);

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        String format3 = localDate.format(dateTimeFormatter);
        System.out.println(format3);

        //String date1="20200708";
        //LocalDate localDate1 = LocalDate.parse(date1, DateTimeFormatter.BASIC_ISO_DATE);
        String date1 = "2020-07-08";
        LocalDate localDate1 = LocalDate.parse(date1, DateTimeFormatter.ISO_LOCAL_DATE);
        System.out.println("parse " + localDate1);

        String date2 = "2020-07-08";
        DateTimeFormatter mySelfFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate localDate2 = LocalDate.parse(date2, mySelfFormatter);
        System.out.println("mySelf parse "+localDate2);
    }
}
